<template>
	<view class="container">
		<!-- <view class="user">
			<image :src="$img_path('/mall/5.png')" mode="aspectFill"></image>
			<view class="right">
				<view class="name">
					昵称昵称
				</view>
				<view class="text">
					12345678910
				</view>
			</view>
		</view> -->
		<view class="top-box">
			<view class="r-1">
				<view class="i">
					<view class="num">
						{{info.order_count}}
					</view>
					<text>订单总数</text>
				</view>
				<view class="i">
					<view class="num">
						<text>￥</text>{{info.order_price}}
					</view>
					<text>订单总金额</text>
				</view>
				<view class="i">
					<view class="num">
						<text>￥</text>{{info.all_money}}
					</view>
					<text>总佣金</text>
				</view>
			</view>
			<view class="r-2">
				<view class="i">
					<view class="num">
						<text>￥</text>{{info.d_money}}
					</view>
					<text>待下发佣金</text>
				</view>
				<view class="i">
					<view class="num">
						<text>￥</text>{{info.succ_money}}
					</view>
					<text>已下发佣金</text>
				</view>
			</view>
		</view>


		<!-- <view class="dete-select">
			<uni-datetime-picker type="date" v-model="startTime" @maskClick="maskClick">
				<view class="date-picker">
					<text v-if="startTime" class="one-row">{{startTime}}</text>
					<text v-else class="placeholder">年/月/日</text>
					<image v-if="startTime" @click.stop="startTime=''" class="close"
						:src="$img_path('/pagesMine/63.png')" mode="widthFix"></image>
					<image v-else :src="$img_path('/pagesMine/74.png')" mode="widthFix"></image>
				</view>
			</uni-datetime-picker>
			<text>-</text>
			<uni-datetime-picker type="date" v-model="startTime" @maskClick="maskClick">
				<view class="date-picker">
					<text v-if="startTime" class="one-row">{{startTime}}</text>
					<text v-else class="placeholder">年/月/日</text>
					<image v-if="startTime" @click.stop="startTime=''" class="close"
						:src="$img_path('/pagesMine/63.png')" mode="widthFix"></image>
					<image v-else :src="$img_path('/pagesMine/74.png')" mode="widthFix"></image>
				</view>
			</uni-datetime-picker>
		</view> -->

		<view class="order-tab">
			<view class="tab-item" :class="i==tab1_index?'select':''" v-for="(item,i) in tabList1" :key="i"
				@click="tab1_index=i,getDlOrder()">
				<text>{{item.text}}</text>
			</view>
		</view>
		<view class="order-tab">
			<view class="tab-item" :class="i==tab2_index?'select':''" v-for="(item,i) in tabList2" :key="i"
				@click="tab2_index=i,getDlOrder()">
				<text>{{item.text}}</text>
			</view>
		</view>

		<view class="list">
			<view v-for="item,index in lsit" :key="index" class="item">
				<view v-for="i,x in item.goods" :key="x" class="goods">
					<image :src="$img_base_url(i.image)" mode="aspectFill"></image>
					<view class="right">
						<view class="r-1">
							<view class="name one-row">
								{{i.title}}
							</view>
							<view class="price">
								<text>¥ </text>{{i.price}}
							</view>
						</view>
						<view class="r-2">
							<view class="spec">
								{{i.difference}}
							</view>
							<view class="num">
								x {{i.number}}
							</view>
						</view>
					</view>
				</view>

				<view class="o-info">
					<view class="i-2">
						<view>
							<text>订单状态：</text> <text v-if="item.state == 2">待发货/待接单</text><text
								v-if="item.state == 3">待收货/进行中</text><text v-if="item.state == 4">待评论</text><text
								v-if="item.state == 6">已完成</text>
						</view>
						<view>
							<text>下单人：</text>{{item.user.nickname}}
						</view>
					</view>
					<view class="i-2">
						<view>
							<text>下单时间：</text>{{item.createtime_text}}
						</view>
						<view>
							<text>佣金：</text>￥{{yongjin(item.goods)}}
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="kong"></view>
	</view>
</template>

<script>
	import * as api from '@/utils/api/index.js'
	export default {
		data() {
			return {
				tabList1: [{
					text: '商品',
					value: 1
				}, {
					text: '服务',
					value: 2
				}],
				tabList2: [{
					text: '待发货/待接单',
					value: 2
				}, {
					text: '待收货/进行中',
					value: 3
				}, {
					text: '待评论',
					value: 4
				}, {
					text: '已完成',
					value: 6
				}, ],
				tab1_index: 0,
				tab2_index: 0,
				startTime: '',
				info: {},
				id: '',
				lsit: []
			};
		},
		onLoad(options) {
			this.id = options.id
			this.getOrderTotal()
			this.getDlOrder()
		},
		onShow() {},
		methods: {
			yongjin(goods){
				let yongjin = 0
				for (var i = 0; i < goods.length; i++) {
					let item =  goods[i]
					yongjin += (item.yongjin * 1)
				}
				return yongjin
			},
			async getDlOrder() {
				let obj = {
					type: this.tabList1[this.tab1_index].value,
					order_state: this.tabList2[this.tab2_index].value,
					user_id: this.id || ''
				}
				const {
					code,
					data
				} = await api.getDlOrder(obj)
				if (code == 1) {
					this.lsit = data.data
				}
			},
			async getOrderTotal() {
				const {
					code,
					data
				} = await api.getOrderTotal({
					user_id: this.id || ''
				})
				if (code == 1) {
					this.info = data
				}
			}
		},

	}
</script>

<style lang="scss" scoped>
	.container {
		padding: 0 22rpx;
		box-sizing: border-box;

		&>.user {
			background-color: #FFFFFF;
			border-radius: 20rpx;
			padding: 38rpx 28rpx 26rpx;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			margin-top: 20rpx;

			image {
				width: 88rpx;
				height: 88rpx;
				border-radius: 50%;
			}

			.right {
				padding-left: 20rpx;

				.name {
					font-weight: bold;
					font-size: 28rpx;
					color: #000000;
					line-height: 40rpx;
				}

				.text {
					font-weight: 400;
					font-size: 24rpx;
					color: #818181;
					line-height: 34rpx;
					margin-top: 4rpx;
				}
			}
		}

		.top-box {
			background: #FFFFFF;
			box-shadow: 0rpx 0rpx 12rpx 2rpx rgba(223, 223, 223, 0.16);
			border-radius: 20rpx;
			box-sizing: border-box;
			margin-top: 20rpx;

			.r-1 {
				display: flex;

				&>view {
					flex: auto;
					padding: 42rpx 30rpx 54rpx;
					box-sizing: border-box;
					display: flex;
					flex-direction: column;
					align-items: center;
					position: relative;

					.num {
						font-weight: bold;
						font-size: 48rpx;
						color: #000000;
						line-height: 66rpx;

						text {
							font-size: 32rpx;
						}
					}

					&>text {
						font-weight: bold;
						font-size: 28rpx;
						color: #333333;
						line-height: 40rpx;
						margin-top: 6rpx;
					}

					&:nth-child(1),
					&:nth-child(2) {
						&::after {
							content: '';
							width: 2rpx;
							height: 76rpx;
							background-color: #DFDFDF;
							position: absolute;
							right: 0;
							top: 50%;
							transform: translateY(-50%);
						}
					}
				}
			}

			.r-2 {
				display: flex;
				width: calc(100% - 60rpx);
				margin: 0 auto;
				box-sizing: border-box;
				border-top: 2rpx solid #DFDFDF;

				&>view {
					flex: 1;
					padding: 24rpx 0rpx 54rpx;
					box-sizing: border-box;
					display: flex;
					flex-direction: column;
					align-items: center;
					position: relative;

					.num {
						font-weight: bold;
						font-size: 48rpx;
						color: #000000;
						line-height: 66rpx;

						text {
							font-size: 32rpx;
						}
					}

					&>text {
						font-weight: bold;
						font-size: 28rpx;
						color: #333333;
						line-height: 40rpx;
						margin-top: 6rpx;
					}

					&:nth-child(1) {
						&::after {
							content: '';
							width: 2rpx;
							height: 76rpx;
							background-color: #DFDFDF;
							position: absolute;
							right: 0;
							top: 50%;
							transform: translateY(-50%);
						}
					}
				}
			}
		}

		.dete-select {
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-top: 20rpx;

			/deep/ .uni-date {
				width: calc(50% - 21rpx) !important;
			}

			.date-picker {
				width: 100%;
				height: 74rpx;
				background: #FFFFFF;
				border-radius: 12rpx 12rpx 12rpx 12rpx;
				// border: 2rpx solid #B4B4B4;
				display: flex;
				align-items: center;
				padding: 0 20rpx;
				box-sizing: border-box;
				position: relative;

				text {
					display: block;
					width: calc(100% - 30rpx);
					font-weight: 400;
					font-size: 28rpx;
					color: #333333;
					line-height: 40rpx;

					&.placeholder {
						color: #B4B4B4;
					}
				}

				image {
					width: 30rpx;
					height: 30rpx;
				}
			}

			text {
				font-weight: 400;
				font-size: 36rpx;
				color: #000000;
				padding: 0 12rpx;
			}
		}

		.order-tab {
			// position: sticky;
			// top: 0;
			// left: 0;
			// right: 0;
			// margin-top: 20rpx;
			padding: 40rpx 0rpx 12rpx;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			justify-content: space-around;
			// background-color: #FFFFFF;
			z-index: 3;

			.tab-item {
				text {
					font-weight: 400;
					font-size: 32rpx;
					color: #333333;
					line-height: 44rpx;
					position: relative;
				}

				&.select {
					text {
						font-weight: bold;
						font-size: 32rpx;
						color: #E72A2A;
						line-height: 44rpx;

						&::after {
							content: '';
							width: 52rpx;
							height: 8rpx;
							background: #E72A2A;
							border-radius: 4rpx;
							position: absolute;
							top: calc(100% + 4rpx);
							left: 50%;
							transform: translateX(-50%);
						}
					}
				}
			}
		}

		.list {
			.item {
				padding: 26rpx 22rpx 24rpx;
				background: #FFFFFF;
				box-shadow: 0rpx 0rpx 12rpx 2rpx rgba(223, 223, 223, 0.16);
				border-radius: 20rpx;
				margin-top: 20rpx;
				box-sizing: border-box;

				.goods {
					display: flex;

					image {
						width: 180rpx;
						height: 180rpx;
						border-radius: 20rpx;
					}

					.right {
						width: calc(100% - 180rpx);
						padding-left: 20rpx;
						box-sizing: border-box;

						.r-1 {
							display: flex;
							align-items: center;
							justify-content: space-between;
							padding-top: 12rpx;

							.name {
								width: calc(100% - 130rpx);
								font-weight: bold;
								font-size: 34rpx;
								color: #333333;
								line-height: 48rpx;
							}

							.price {
								font-weight: 900;
								font-size: 42rpx;
								color: #FF2E2E;
								line-height: 58rpx;

								text {
									font-size: 32rpx;
								}
							}
						}

						.r-2 {
							padding-top: 30rpx;
							font-weight: bold;
							font-size: 28rpx;
							color: #333333;
							line-height: 40rpx;
							display: flex;
							align-items: center;
							justify-content: space-between;
						}
					}
				}

				.o-info {
					margin-top: 12rpx;

					&>view {
						display: flex;
						align-items: center;
						justify-content: space-between;
						font-weight: bold;
						font-size: 28rpx;
						color: #000000;
						line-height: 40rpx;

						text {
							font-weight: 500;
						}

						padding-top: 16rpx;
					}
				}
			}
		}
	}
</style>